<ui:composition template="/WEB-INF/templates/showcase.xhtml" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core" 
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:o="http://omnifaces.org/ui"
>
	<ui:define name="description">
		<p>
			The	<code>&lt;o:form&gt;</code>	extends the standard <code>&lt;h:form&gt;</code>
			and provides support for including all URL (GET) parameters in the URL that's used for the post-back, or only
			those that are also view parameters.
		</p>
		<p>
			By setting the <b><code>includeViewParams</code></b> attribute to true (default is false),
			the current value of every view parameter will be added to the action URL that will be rendered
			on the form. This is similar to how the attribute of the same name can be used on the
			<code>&lt;h:link&gt;</code> and	<code>&lt;h:button&gt;</code> components.
		</p>
		<p>
			In case all URL (GET) parameters are needed, the <b><code>includeRequestParams</code></b> attribute
			can be set to true (default is false). If both <code>includeRequestParams</code> and 
			<code>includeViewParams</code> are set to true <code>includeRequestParams</code> will take precedence. 
			
		</p>
	</ui:define>

	<ui:define name="demo-meta">
		<f:metadata>
			<o:viewParam id="test" name="test" value="#{viewParamBean.test}" />
		</f:metadata>
	</ui:define>

	<ui:define name="demo">
		<p>
			First do a GET request to the current page to start using a view parameter.
		</p>
		<p>
			<h:link value="Do GET request with view param">
				<f:param name="test" value="foo" />
			</h:link>
		</p>

		<p>
			Then, do one or more POSTs in an o:form to see that the GET parameter that's been used as a 
			view parameter in the URL is preserved.
		</p>
		<o:form includeViewParams="true">
			<h:commandLink value="POST-BACK o:form with includeViewParams" action="#{viewParamBean.action}" />
		</o:form>
		
		<p>
			Now do a GET request to the current page to additionally start using GET parameters which are NOT 
			also view parameters.
		</p>
		<p>
			<h:link value="Do GET request with a view param and free GET parameters">
				<f:param name="test" value="000" />
				<f:param name="foo" value="123" />
				<f:param name="foo" value="456" />
				<f:param name="bar" value="xxx" />
			</h:link>
		</p>
		
		<p>
			Then, do one or more POSTs in an o:form with includeRequestParams to see that all the GET parameters 
			are being preserverd in the URL (try to post back the "includeViewParams form" to see that only the view 
			param will be preserved)
		</p>
		<o:form includeRequestParams="true">
			<h:commandLink value="POST-BACK o:form with includeRequestParams" action="#{viewParamBean.action}" />
		</o:form>

		<p>
			Finally, do a POST via an h:form to see that all the GET parameter in URL disappears.
		</p>
		<h:form>
			<h:commandLink value="POST-BACK h:form" action="#{viewParamBean.action}" />
		</h:form>

		<p>
			<b>The value:</b> #{viewParamBean.test}
		</p>
	</ui:define>
</ui:composition>